package com.guigu.www.denghao.controller;

import com.guigu.www.denghao.service.DHMemberService;
import com.guigu.www.pojo.Member;
import com.guigu.www.pojo.MemberCaseHistory;
import com.guigu.www.pojo.MemberTrends;
import com.guigu.www.pojo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/DHMemberController")
public class DHMemberController {

    @Autowired
    private DHMemberService dhMemberService;

    @PostMapping("/initMember")
    public PageVo<Member> initMember(Integer pageNum,Integer pageSize,String memName,String memPhone,String memAge){
        return dhMemberService.initMember(pageNum,pageSize,memName,memPhone,memAge);
    }

    @PostMapping("/addMember")
    public Integer addMember(@RequestBody Member member){
        System.out.println(member);
        dhMemberService.addMember(member,member.getTrends(),member.getCaseHistory());
        return 0;
    }

    @PutMapping("/upMember")
    public Integer upMember(@RequestBody Member member){
        dhMemberService.upMember(member, member.getTrends(),member.getCaseHistory());
        return 0;
    }

    @PostMapping("/queryByMemIdMember")
    public Member queryByMemIdMember (Integer memId){
        return dhMemberService.queryByMemIdMember(memId);
    }

    @PostMapping("/queryByMemIdTrends")
    public MemberTrends queryByMemIdTrends (Integer memId){
        return dhMemberService.queryByMemIdTrends(memId);
    }

    @PostMapping("/queryByMemIdCaseHistory")
    public MemberCaseHistory queryByMemIdCaseHistory (Integer memId){
        return dhMemberService.queryByMemIdCaseHistory(memId);
    }

    @PutMapping("/upMemState")
    public Integer upMemState(Integer memId,Integer memState){
        return dhMemberService.upMemState(memId,memState);
    }
}
